package com.example.javamediaserver.repository;

import com.example.javamediaserver.model.StreamSession;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface StreamSessionRepository extends JpaRepository<StreamSession, String> {

    List<StreamSession> findByAppAndStreamKey(String app, String streamKey);
    
    List<StreamSession> findByEndTimeIsNull();
    
    List<StreamSession> findByIsRecordingTrue();
    
    @Query("SELECT s FROM StreamSession s WHERE s.startTime >= :startTime ORDER BY s.startTime DESC")
    List<StreamSession> findRecentSessions(LocalDateTime startTime);
} 